package com.example.flower_shop.dto.review;

import com.example.flower_shop.entity.ReviewReply;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
public class ReviewReplyDTO {
    private Long id;
    private Long userId;
    private String username;
    private String userAvatar;
    private Long reviewId;

    @NotBlank(message = "回复内容不能为空")
    private String content;

    private Integer likesCount;
    private LocalDateTime createTime;
    private Boolean isLiked = false;

    public ReviewReplyDTO(ReviewReply reply) {
        this.id = reply.getId();
        this.userId = reply.getUser().getId();
        this.username = reply.getUser().getUsername();
        this.userAvatar = reply.getUser().getAvatarUrl();
        this.reviewId = reply.getParentReview().getId();
        this.content = reply.getContent();
        this.likesCount = reply.getLikesCount();
        this.createTime = reply.getCreateTime();
    }
}